package command

import (
	"bufio"
	"log"
	"os/exec"
)

// Run 执行命令
func Run(name string, args ...string) {
	log.Println(name, args)
	cmd := exec.Command(name, args...)
	stderr, _ := cmd.StderrPipe()
	stdout, err := cmd.Output()

	log.Println(string(stdout))
	if err != nil {
		scanner := bufio.NewScanner(stderr)
		for scanner.Scan() {
			log.Println(scanner.Text())
		}
		log.Panic(err)
	}

}
